<?php include('functions.php');
function basicTemplate($meta,$content) {
global $ver;
echo <<<TMP
<html>
<head>
<title>oPanel V{$ver}</title>
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet"href="style.css">
{$meta}
</head>
<body>
{$content}
</body>
</html>
TMP;
}

if(!isset($_SESSION["pass"]) || !isset($_SESSION["user"])) { 
$meta = '<script>
parent.location="http://'.$_SERVER["HTTP_HOST"].dirname("$_SERVER[SCRIPT_NAME]").'/";
</script>';
basicTemplate($meta,'');
exit;
}
if ($_SESSION["pass"] == check($_SESSION["user"])) {
if(isset($_GET['newPassword'])) {
if(updatePass($_SESSION["user"],$_GET['newPassword']) === false) { echo 'Failed'; } else { echo 'changed';  $_SESSION["pass"] = crypt(md5($_GET['newPassword']), md5($_SESSION["user"])); }
exit;
}
$content = '<center><img src="images/logo.png"></center>';
if($_SESSION["power"] == 'Administrator') { $content .= '<a href="admin.php" target="_blank">Launch Admin Control Panel</a>'; }
}
basicTemplate('',$content);
?>